package com.huifer.wgx.pojo;

import lombok.Getter;
import lombok.Setter;

/**
 * <p>Title : CommonResult </p>
 * <p>Description : 通用返回对象</p>
 *
 * @author huifer
 * @date 2019-03-18
 */
@Getter
@Setter
public class CommonResult {

    /**
     * 操作成功
     */
    public static final int SUCCESS = 200;

    /**
     * 操作失败
     */
    public static final int FAILED = 500;

    /**
     * 状态码
     */
    private int code;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 返回数据
     */
    private Object data;

    /**
     * 操作成功返回
     *
     * @param data 操作数据
     * @return {@link CommonResult}
     */
    public CommonResult success(Object data) {
        this.code = SUCCESS;
        this.message = "操作成功";
        this.data = data;
        return this;
    }

    /**
     * 操作失败返回
     *
     * @return {@link CommonResult}
     */
    public CommonResult fialed(Object data) {
        this.code = FAILED;
        this.message = "操作失败";
        this.data = data;
        return this;
    }


}
